# Makefile for the MetaPost support programs.

kpse_include ../make/paths.mk
kpse_include ../make/common.mk
kpse_include ../make/programs.mk
kpse_include kpathsea.mk

proglib = ../lib/lib.a
programs = dmp mpto newer makempx

default: all
all: $(programs) 

dmp: dmp.o dmp_ffile.o
	$(kpathsea_link) dmp.o dmp_ffile.o $(LOADLIBES)
mpto: mpto.o
	$(kpathsea_link) mpto.o
newer: newer.o
	$(link_command) newer.o
makempx: makempx.o
	$(kpathsea_link) makempx.o $(LOADLIBES)

dmp.o dmp_ffile.o:  dmp.h

newer.o dmp.o makempx.o: ../c-auto.h

checkdir = $(srcdir)/../check
check: mpto makempx newer dmp
	makempx $(checkdir)/label.mp ../check/xlabel.mpx
	./mpto -tex $(checkdir)/testex.mp | diff $(checkdir)/testex.tex -
	sed '16s/^%//' <$(checkdir)/testex.mp >testex1
	-mpto -tex testex1 >/dev/null 2>testex2
	sed '17s/^%//' <$(checkdir)/testex.mp >testex1
	-mpto -tex testex1 >/dev/null 2>>testex2
	sed '18s/^%//' <$(checkdir)/testex.mp >testex1
	-mpto -tex testex1 >/dev/null 2>>testex2
	sed '19s/^%//' <$(checkdir)/testex.mp >testex1
	-mpto -tex testex1 >/dev/null 2>>testex2
	sed '20s/^%//' <$(checkdir)/testex.mp >testex1
	-mpto -tex testex1 >/dev/null 2>>testex2
	diff $(checkdir)/testex.err testex2

Makefile: Makefile.in ../config.status
	cd .. && $(SHELL) config.status

install: install-exec install-data
install-exec: $(programs)
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir) $(scriptdir)
	$(INSTALL_PROGRAM) newer $(bindir)/newer
	$(INSTALL_LIBTOOL_PROG) dmp $(bindir)
	$(INSTALL_LIBTOOL_PROG) mpto $(bindir)
	$(INSTALL_SCRIPT) makempx $(scriptdir)/makempx
install-data:

kpse_include ../make/tkpathsea.mk
kpse_include ../make/clean.mk

mostlyclean::
	rm -f testex1 testex2

kpse_include ../make/rdepend.mk
kpse_include mpware/depend.mk
